package com.coolgor.coldot.handler;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import com.coolgor.coldot.exceptions.auth.LocalUserOperationException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;


@ControllerAdvice
public class GlobalExceptionHandler {

	@ExceptionHandler(value = LocalUserOperationException.class)
	@ResponseBody
	private Map<String, Object> LocalUserOperationExceptionHandler(HttpServletRequest req, LocalUserOperationException e) {
		Map<String, Object> modelMap = new HashMap<String, Object>();
		System.out.println("[LocalUser Operation error]>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
		System.out.println(e.getMessage());
		modelMap.put("success", false);
		modelMap.put("errMsg", "Policy Operation error!");
		return modelMap;		
	}
}
